package com.sc.service.impl.patrol;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.domain.patrol.PatrolPoint;
import com.sc.dto.PatrolPointDTO;
import com.sc.mapper.patrol.PatrolPointMapper;
import com.sc.result.PageResult;
import com.sc.service.patrol.PatrolPointService;
import com.sc.vo.PatrolPathVO;
import com.sc.vo.PatrolPointVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 巡检点
 * @author: Zuiliu
 * 添加服务层实现类
 **/
@Service
public class PatrolPointServiceImpl extends ServiceImpl<PatrolPointMapper, PatrolPoint> implements PatrolPointService {

    @Override
    public PageResult<PatrolPointVO> pageQuery(PatrolPointDTO patrolPointDTO) {
        int start = (patrolPointDTO.getPageNum() - 1) * patrolPointDTO.getPageSize();
        int end = patrolPointDTO.getPageNum() * patrolPointDTO.getPageSize();

        List<PatrolPointVO> list = baseMapper.pageQuery(patrolPointDTO);
        PageResult<PatrolPointVO> page = new PageResult<>(list.size(), list.subList(start, Math.min(list.size(), end)));
        return page;
    }
}